package com.hidt.shop.mapper;

import com.hidt.shop.domain.CartAndGoods;
import com.hidt.shop.domain.Collection;
import com.hidt.shop.domain.CollectionAndGoods;
import com.hidt.shop.domain.Goods;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface CollectionMapper {
    /**
     * 通过用户id和商品id查看收藏信息判断该商品是否收藏过
     * 查询到显示已收藏，未查询到显示收藏
     *@参数  collection
     *@返回值  Collection
     *@创建人  lmf
     *@创建时间  2021/1/20
     */
    @Select("select * from collection where id=#{id} and good_id=#{good_id}")
    Collection FindCollection(Collection collection);
    /**
     * 添加收藏
     *@参数  collection
     *@返回值  int
     *@创建人  lmf
     *@创建时间  2021/1/20
     */
    @Insert("insert into collection (id,good_id) values(#{id},#{good_id})")
    int AddCollection(Collection collection);
    /**
     * 通过id查看收藏
     *@参数  id
     *@返回值  List<CollectionAndGoods>
     *@创建人  lmf
     *@创建时间  2021/1/20
     */
   @Select("select goods.good_name,goods.good_picture,goods.good_id,goods.goodsale_price,goods_discount,seckil_discount from collection,goods where id=#{id} and goods.good_id=collection.good_id and goods.goodis_delete=0")
    List<CollectionAndGoods> FindAllCollection(int id);

    /**
     * 通过id删除收藏
     *@参数  collection
     *@返回值  int
     *@创建人  lmf
     *@创建时间  2021/1/20
     */
    @Delete("delete from collection where good_id=#{good_id} and id=#{id}")
    int DeleteCollection(Collection collection);
}
